import javax.swing.*; import java.awt.*; import java.awt.geom.*; import java.awt.event.*; import java.io.*; import java.util.*;; public class Graphing_tool extends JFrame implements ActionListener{ JFrame Error_message_enter_file_name = new JFrame("Error message"); JFrame Error_message_file_not_present = new JFrame("Error message"); private JFrame Graph_Frame = new JFrame(); private Draw_line graph_constructor = new Draw_line(); JLabel enter_file_name_error = new JLabel("Enter the file name please."); JLabel file_not_present_error = new JLabel("The file does not exits"); JLabel Protein_name = new JLabel("Protein name"); JTextField display = new JTextField("Enter file location here.",40); JCheckBox Disorderness = new JCheckBox("Disorderness"); JCheckBox Secondary_structures = new JCheckBox("Secondary_structures"); JCheckBox Sequence_conservation = new JCheckBox("Sequence_conservation"); JCheckBox Antigenicity = new JCheckBox("Antigenicity"); JCheckBox Hydrophilicity = new JCheckBox("Hydrophilicity"); JCheckBox Concensus = new JCheckBox("Concensus"); JCheckBox Window_sliding = new JCheckBox("Window_sliding"); JButton Draw = new JButton("Draw"); public Graphing_tool(){ Panel panel_text = new Panel(); Panel panel_options_1 = new Panel(); Panel panel_options_2 = new Panel(); panel_text.add(Protein_name); panel_text.add(display); panel_options_1.add(Disorderness); panel_options_1.add(Secondary_structures); panel_options_1.add(Sequence_conservation); panel_options_2.add(Antigenicity); panel_options_2.add(Hydrophilicity); panel_options_2.add(Concensus); panel_options_2.add(Window_sliding); setTitle("Fateh's Graphing Tool"); getContentPane().setLayout(null); getContentPane().setBackground(Color.white); getContentPane().add(panel_text); getContentPane().add(panel_options_1); getContentPane().add(panel_options_2); getContentPane().add(Draw); panel_text.setBounds(0,50,800,40); panel_options_1.setBounds(100,100,600,40); panel_options_2.setBounds(100,150,600,40); Draw.setBounds(350,200,75,40); Draw.addActionListener(this); Graph_Frame.getContentPane().add(graph_constructor); Graph_Frame.setBackground(Color.white); Graph_Frame.pack(); Graph_Frame.setTitle("Graph of the requested items"); } public void actionPerformed(ActionEvent Click){ System.out.println("Button was Clicked!!"); if(Click.getSource() == Draw){ String File_name = display.getText(); System.out.println("File name - "+File_name); File final_out_file = new File(File_name); if (File_name.equals("Enter file location here.")){ display_error_enter_file_name(); }else if(!final_out_file.exists()){ display_error_file_does_not_exist(); }else{ try { parse_file(File_name); } catch (IOException e) {} } } } public void parse_file(String File_name) throws IOException { BufferedReader infile = null; String line; int number_of_lines = count_lines(File_name); double[] Disorder_array = new double[number_of_lines]; double[] Sec_str_array = new double[number_of_lines]; double[] Seq_cons_array = new double[number_of_lines]; double[] Antigene_array = new double[number_of_lines]; double[] Hydro_array = new double[number_of_lines]; double[] Sum_array = new double[number_of_lines]; double[] Window_array = new double[number_of_lines]; int number_of_options_selected = 0; int array_of_bools [] = new int[7]; boolean Disorder = false,Sec_str = false,Seq_cons = false,Antigene = false,Hydro = false,Sum = false,Window = false; if(Disorderness.isSelected()){ Disorder = true; number_of_options_selected++; array_of_bools[0] = 1; }if(Secondary_structures.isSelected()){ Sec_str = true; number_of_options_selected++; array_of_bools[1] = 1; }if(Sequence_conservation.isSelected()){ Seq_cons = true; number_of_options_selected++; array_of_bools[2] = 1; }if(Antigenicity.isSelected()){ Antigene = true; number_of_options_selected++; array_of_bools[3] = 1; }if(Hydrophilicity.isSelected()){ Hydro = true; number_of_options_selected++; array_of_bools[4] = 1; }if(Concensus.isSelected()){ Sum = true; number_of_options_selected++; array_of_bools[5] = 1; }if(Window_sliding.isSelected()){ Window = true; number_of_options_selected++; array_of_bools[6] = 1; } System.out.println(Disorder + " " + Sec_str + " " + Seq_cons + " " + Antigene + " " + Hydro + " " + Sum + " " + Window); int counter = 0; infile = new BufferedReader(new FileReader(File_name)); while((line = infile.readLine()) != null){ String nums[] = line.split(" "); Disorder_array[counter] = Double.parseDouble(nums[3]); Sec_str_array[counter] = Double.parseDouble(nums[4]); Seq_cons_array[counter] = Double.parseDouble(nums[5]); Antigene_array[counter] = Double.parseDouble(nums[6]); Hydro_array[counter] = Double.parseDouble(nums[7]); Sum_array[counter] = Double.parseDouble(nums[9]); if (counter